/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

/**
 *
 * @author Admin
 */
@Entity
@Table(name = "leadprofile")
@NamedQueries({
    @NamedQuery(name = "Leadprofile.findAll", query = "SELECT l FROM Leadprofile l")})
public class Leadprofile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @ManyToOne
    @JoinColumn(name = "source")
    private SetupsValue source;
    @ManyToOne
    @JoinColumn(name = "category", nullable = false)
    private SetupsValue category;
    @ManyToOne
    @JoinColumn(name = "grade", nullable = false)
    private SetupsValue grade;
    @ManyToOne
    @JoinColumn(name = "stage", nullable = false)
    private SetupsValue stage;
    @ManyToOne
    @JoinColumn(name = "action", nullable = false)
    private SetupsValue action;
    @ManyToOne
    @JoinColumn(name = "closingProbability", nullable = false)
    private SetupsValue closingProbability;
    @Basic(optional = false)
    @Column(name = "companySize", nullable = false)
    private int companySize;
    @Basic(optional = false)
    @Column(name = "annualRevenue", nullable = false)
    private double annualRevenue;
    @Basic(optional = false)
    @Lob
    @Column(name = "notes", nullable = false)
    private byte[] notes;
    @JoinColumn(name = "lead_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Lead lead;
    @JoinColumn(name = "assignedSalesPerson", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false, cascade = CascadeType.REFRESH)
    private Employee employee;
    
	@ManyToOne(cascade=CascadeType.REFRESH)
	@JoinColumn(name="createdBy", referencedColumnName="username")
	private CrmUser createdBy;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="createdat")
	private Date createdAt;

    public Leadprofile() {
    }

    public Leadprofile(Integer id) {
        this.id = id;
    }

    public Leadprofile(Integer id, SetupsValue source, SetupsValue category, SetupsValue grade, SetupsValue stage, SetupsValue action, SetupsValue closingProbability, int companySize, double annualRevenue, byte[] notes) {
        this.id = id;
        this.source = source;
        this.category = category;
        this.grade = grade;
        this.stage = stage;
        this.action = action;
        this.closingProbability = closingProbability;
        this.companySize = companySize;
        this.annualRevenue = annualRevenue;
        this.notes = notes;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

   
    public SetupsValue getSource() {
		return source;
	}

	public void setSource(SetupsValue source) {
		this.source = source;
	}

	public SetupsValue getCategory() {
		return category;
	}

	public void setCategory(SetupsValue category) {
		this.category = category;
	}

	public SetupsValue getGrade() {
		return grade;
	}

	public void setGrade(SetupsValue grade) {
		this.grade = grade;
	}

	public SetupsValue getStage() {
		return stage;
	}

	public void setStage(SetupsValue stage) {
		this.stage = stage;
	}

	public SetupsValue getAction() {
		return action;
	}

	public void setAction(SetupsValue action) {
		this.action = action;
	}

	public SetupsValue getClosingProbability() {
		return closingProbability;
	}

	public void setClosingProbability(SetupsValue closingProbability) {
		this.closingProbability = closingProbability;
	}

	public int getCompanySize() {
        return companySize;
    }

    public void setCompanySize(int companySize) {
        this.companySize = companySize;
    }

    public double getAnnualRevenue() {
        return annualRevenue;
    }

    public void setAnnualRevenue(double annualRevenue) {
        this.annualRevenue = annualRevenue;
    }

    public byte[] getNotes() {
        return notes;
    }

    public void setNotes(byte[] notes) {
        this.notes = notes;
    }

    public Lead getLead() {
        return lead;
    }

    public void setLead(Lead lead) {
        this.lead = lead;
    }

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}

	public CrmUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Leadprofile)) {
            return false;
        }
        Leadprofile other = (Leadprofile) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.crm.domain.Leadprofile[id=" + id + "]";
    }

}
